package org.roulette.utils;

import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 *
 * @author Alpha
 */
public class Configuration {
	private static final String STATIC_NUMBER_FILES_DIRECTORY = "/static";

	public static List<File> getStaticNumberFiles(final RouletteType type){
		String dirString = Configuration.class.getResource(STATIC_NUMBER_FILES_DIRECTORY).getFile();
		File dir = new File(dirString);
		File[] files = dir.listFiles(new FilenameFilter(){
			public boolean accept(File dir, String name) {
				return isFileToLoad(name, type);
			}
		});
		return Arrays.asList(files);
	}

	public static List<File> getStaticNumberFiles(final RouletteType type, File... filesToLoad){
		List<File> result = new ArrayList<File>();
		result.addAll(getStaticNumberFiles(type));
		for(File file: filesToLoad){
			if(file.isFile() && isFileToLoad(file.getName(), type)){
				result.add(file);
			}
		}
		return result;
	}

	private static boolean isFileToLoad(String filename, final RouletteType type){
		return filename.contains(type.name());
	}


}
